//
//  HDCFRiskLevelVc.m
//  HaoDeCaiFu
//
//  Created by 郑开宏 on 2017/11/15.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "HDCFRiskLevelVc.h"
#import "HDCFRiskTestVc.h"
#import "SVProgressHUD.h"
#import "HDCFAccountSetVc.h"

@interface HDCFRiskLevelVc ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *labelOne;
@property (weak, nonatomic) IBOutlet UILabel *labelTwo;
@property (weak, nonatomic) IBOutlet UIButton *repeatBtn;
@property (weak, nonatomic) IBOutlet UIButton *popBtn;

@end

@implementation HDCFRiskLevelVc

- (void)setIsRoot:(BOOL)isRoot{
    _isRoot = isRoot;
}

- (void)setRiskLevel:(NSInteger)riskLevel{
    _riskLevel = riskLevel;
}
- (IBAction)repeatBtnClick:(UIButton *)sender {
    HDCFRiskTestVc *vc = [[HDCFRiskTestVc alloc] init];
    vc.isNormal = YES;
    [self.navigationController pushViewController:vc animated:YES];
}
- (IBAction)IKnowClick:(UIButton *)sender {

    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
    NSNotification *notification = [[NSNotification alloc] initWithName:@"refreshAccountSet" object:nil userInfo:nil];
    [[NSNotificationCenter defaultCenter] postNotification:notification];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setTitle:@"风险评测结果"];
    if (_isRoot == YES) {
        self.popBtn.hidden = YES;
    }
    if (_riskLevel == 1) {
        _imgView.image = [UIImage imageNamed:@"保守型2"];
    }else if (_riskLevel == 2){
        _imgView.image = [UIImage imageNamed:@"中度保守型2"];
    }else if (_riskLevel == 3){
        _imgView.image = [UIImage imageNamed:@"平衡型2"];
    }else if (_riskLevel == 4){
        _imgView.image = [UIImage imageNamed:@"中度进取型2"];
    }else{
        _imgView.image = [UIImage imageNamed:@"进取型2"];
    }
    [self getData];
}

- (void)getData{
    
    [SVProgressHUD show];
    NSString *str = [NSString stringWithFormat:@"%ld", _riskLevel];
    NSDictionary *dict = @{@"riskRating":str};
    [HttpRequest sendSelfGetRequestWithURL:@"api/Info4IFAST/GetRiskAppetiteResultDesc" WithParamets:dict success:^(id result) {
        NSNumber *number = result[@"code"];
        if ([number isEqual:@1]) {
            [SVProgressHUD dismiss];
            NSDictionary *dict = result[@"result"];
            self.labelOne.text = dict[@"riskDescription_title"];
            self.labelTwo.text = dict[@"riskDescription_point"];
        }else{
            [SVProgressHUD showInfoWithStatus:result[@"msg"]];
            [SVProgressHUD dismissWithDelay:1.0];
        }
        
    } failure:^(NSError *errer) {
        [SVProgressHUD showErrorWithStatus:@"服务器错误"];
        [SVProgressHUD dismissWithDelay:1.0];
    }];
}

@end
